﻿@{
    ViewBag.Title = "wyg";
    Layout = "~/Views/Shared/_LayoutPage1.cshtml";
}

<h2>wyg</h2>
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/jquery-1.7.1.min.js"></script>
</head>
<body>
    <div>
        科室  <select id="sel1"><option selected="selected" value="0">请选择</option></select><input id="Button1" type="button" value="搜索" onclick="cha()" />

        医生<select id="sel2"></select>
        科室  <select id="list1"></select>

        <table id="tab1" class="table ui-selectable-helper">
            <tbody>

                <tr>
                    <th>编号</th>
                    <th>专家</th>
                    <th>专家名称</th>
                    <th>上班时间</th>
                    <th>下班时间</th>
                    <th>每天挂号数量</th>
                    <th>专家介绍</th>
                    <th>专家坐诊状态</th>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>
<script>
    $(function () {
        $.ajax({
            url: "http://localhost:13936/actionapi/values/typelist",
            type: "get",
            dataType: "json",
            data: { zid: 0 },
            success: function (p) {
                for (var i = 0; i < p.length; i++) {
                    $("#sel1").append("<option value='" + p[i].kid + "' >" + p[i].kname + "</option>");
                }
                typesinfo($("#sel1").val());
            }
        })
        $("#sel1").change(function () {
            $("#sel2").empty();
            typesinfo($("#sel1").val());

        })
    })
    function typesinfo(zid) {
        $.ajax({
            url: "http://localhost:13936/actionapi/values/typelist",
            type: "get",
            dataType: "json",
            data: { zid: zid },
            success: function (a) {
                for (var i = 0; i < a.length; i++) {
                    $("#sel2").append(" <option value='" + a[i].kid + "'>" + a[i].kname + "</option>");
                }
            }
        })
    }
    //   /显示数据
    $(function () {
        $.ajax({
            url: "http://localhost:13936/actionapi/values/chaxun",
            type: "get",
            dataType: "json",
            data: { zid: $("#sel1").val() },
            success: function (a) {
                var str = ""
                $("#tab1").empty();
                for (var i = 0; i < a.length; i++) {
                    str += "<tr>"
                    str += "<td>" + a[i].zid + "</td>"
                    str += "<td>" + a[i].kname + "</td>"
                    str += "<td>" + a[i].zname + "</td>"
                    str += "<td>" + a[i].zcdate + "</td>"
                    str += "<td>" + a[i].cdate + "</td>"
                    str += "<td>" + a[i].znum + "</td>"
                    str += "<td>" + a[i].zcontent + "</td>"
                    str += "<td>" + (a[i].flag == 1 ? "坐诊中" : "停诊中"); +"</td>"
                    str += "<td>" + '<input id="Button1" type="button" value="预约"  onclick="add()"/>' + "</td>"
                    str += "</tr>"
                }
                $("#tab1").append(str);
            }
        })
    })
    function cha() {
        var id = $("#sel1").val();
        $.ajax({
            url: "http://localhost:13936/actionapi/values/chaxun",
            type: "get",
            dataType: "json",
            data: { zid: id },
            success: function (a) {
                var str = ""
                $("#tab1").empty();
                for (var i = 0; i < a.length; i++) {
                    str += "<tr>"
                    str += "<td>" + a[i].zid + "</td>"
                    str += "<td>" + a[i].kname + "</td>"
                    str += "<td>" + a[i].zname + "</td>"
                    str += "<td>" + a[i].zcdate + "</td>"
                    str += "<td>" + a[i].cdate + "</td>"
                    str += "<td>" + a[i].znum + "</td>"
                    str += "<td>" + a[i].zcontent + "</td>"
                    str += "<td>" + (a[i].flag == 1 ? "坐诊中" : "停诊中"); +"</td>"
                    str += "<td>" + '<input id="Button1" type="button" value="预约"  onclick="add()"/>' + "</td>"
                    str += "</tr>"
                }
                $("#tab1").append(str);
                function add() {
                    var i = a[i].znum;
                    if(i>0)
                    {
                        location.href = '/home/addinfo';
                    }
                    else
                    {
                        alert("不好意思今天号已经挂完");
                    }
                }
            }

        })

    }

</script>